package com.ruoyi.gis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.gis.vo.GisIconFileVo;
import com.ruoyi.gis.vo.SamFileVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gis.domain.GisIconBase;
import com.ruoyi.gis.service.IGisIconBaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件信息Controller
 *
 * @author rww
 * @date 2023-12-19
 */
@RestController
@RequestMapping("/gis/iconBase")
public class GisIconBaseController extends BaseController
{
    @Autowired
    private IGisIconBaseService gisIconBaseService;

    /**
     * 查询文件信息列表
     */
    @PreAuthorize("@ss.hasPermi('iconBase:iconBase:list')")
    @GetMapping("/list")
    public TableDataInfo list(GisIconBase gisIconBase)
    {
        startPage();
        List<GisIconBase> list = gisIconBaseService.selectGisIconBaseList(gisIconBase);
        return getDataTable(list);
    }

    @GetMapping("/list/all")
    public AjaxResult listAll(GisIconBase gisIconBase)
    {
        List<GisIconBase> list = gisIconBaseService.selectGisIconBaseList(gisIconBase);
        return AjaxResult.success(list);
    }

    /**
     * 导出文件信息列表
     */
    @PreAuthorize("@ss.hasPermi('iconBase:iconBase:export')")
    @Log(title = "文件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GisIconBase gisIconBase)
    {
        List<GisIconBase> list = gisIconBaseService.selectGisIconBaseList(gisIconBase);
        ExcelUtil<GisIconBase> util = new ExcelUtil<GisIconBase>(GisIconBase.class);
        util.exportExcel(response, list, "文件信息数据");
    }

    /**
     * 获取文件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('iconBase:iconBase:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gisIconBaseService.selectGisIconBaseById(id));
    }

    /**
     * 新增文件信息
     */
    @PreAuthorize("@ss.hasPermi('iconBase:iconBase:add')")
    @Log(title = "文件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GisIconBase gisIconBase)
    {
        return toAjax(gisIconBaseService.insertGisIconBase(gisIconBase));
    }

    @PostMapping("addFiles")
    public AjaxResult addFiles(@RequestBody List<GisIconFileVo> iconFileVos)
    {
        return toAjax(gisIconBaseService.addFiles(iconFileVos));
    }

    /**
     * 修改文件信息
     */
    @PreAuthorize("@ss.hasPermi('iconBase:iconBase:edit')")
    @Log(title = "文件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GisIconBase gisIconBase)
    {
        return toAjax(gisIconBaseService.updateGisIconBase(gisIconBase));
    }

    /**
     * 删除文件信息
     */
    @PreAuthorize("@ss.hasPermi('iconBase:iconBase:remove')")
    @Log(title = "文件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gisIconBaseService.deleteGisIconBaseByIds(ids));
    }
}
